//浏览记录listview
import React, { Component } from 'react'
import {
    View,
    Text,
    Image,
    TouchableOpacity,
} from 'react-native';

import { Position_tradeStyle as styles } from '../../../../styles';
import sal from '../../../util/sal';
import fmt from '../../../util/fmtDateUtil';

var Dimensions = require('Dimensions');
var width = Dimensions.get('window').width;
var height = Dimensions.get('window').height;

export default class Tradep_list extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        return (
            <TouchableOpacity
                style={styles.tra_pall}
                onPress={() => { this.goGet('Postionin', this.props.postion.postionId); }}     //点击时候进入详情页面
                activeOpacity={1}>
                <View style={styles.tra_pev}>
                    <Text style={styles.tra_pname}>{this.props.postion.postionName}</Text>
                    <Text style={styles.tra_pmoney}>{sal(this.props.postion.postionMm, this.props.postion.postionYm)}</Text>
                </View>
                <View style={styles.tra_pev2}>
                    <Text style={styles.tra_one}>{this.props.postion.postionSpace}</Text>
                    <Text style={styles.tra_one}>{this.props.postion.postionExp}年经验</Text>
                    <Text style={styles.tra_one}>{this.props.postion.postionEducation}</Text>
                    <Text style={styles.tra_ptime}>{fmt(this.props.postion.postionTime, "yyyy-MM-dd")}</Text>
                </View>
                <View style={styles.tra_pev3}>
                    <Image source={require('../../../img/app/logo.png')} style={styles.head} />
                    <View style={styles.tra_pth}>
                        <Text style={styles.tra_cname}>{this.props.company.companyName}</Text>
                        <Text style={styles.tra_ptwo}>{this.fieldName(this.props.fields, 3)}</Text>
                    </View>
                </View>
            </TouchableOpacity>
        )
    }

    //经营领域
    fieldName(List, sl) {
        var data = {
            cont: List
        }
        var arr = '';                            //用来装公司类型
        var s = sl;
        var length = data.cont.length
        if (length <= s) {
            s = length
        }
        for (var i = 0; i < s; i++) {
            arr += data.cont[i].fieldName + '/';
        }
        if (arr.endsWith('/')) {
            arr = arr.substr(0, arr.length - 1);
        }
        return arr;
    }

    goGet(name, id) {
        this.props.navigation.navigate(name, { useId: id });
    }

}